<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/11
 * Time: 14:01
 */

namespace App\Models;
//基础模型类使用use加载Illuminate\Database\Eloquent\Model
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;

class UserModel extends Model{
    //确定联系的数据库名称
    protected $table = "tfzy_zhgd_user";

    //关闭掉数据库中，因缺少create_at 和update_at而无法插入的情况
    public $timestamps = false;


    //如果控制器用到$fill 函数的话，就需要在model这，定义哪些字段可以进行插入---添加
    protected $fillable = [
      "name","phone","password","realname"
    ];

    public  static  function check($username,$password){
        $user = UserModel::where(["phone"=>$username])->first();
        if($user !==null){
            //验证密码是否正确
            if(Hash::check($password,$user->password)){
                return true;
            }else{
                return false;
            }
        }else{
            //找不到用户的时候返回false
            return false;
        }
    }


}